import { http } from '@/utils/http'
import { PostMemberAddressData, MemberAddressItem } from '@/types/address'
/**
 * 添加收货地址
 * @param data
 * @returns
 */
export const postMemberAddress = (data: PostMemberAddressData) =>
  http({
    url: '/member/address',
    method: 'POST',
    data,
  })

/**
* 获取收货地址列表
* @returns
*/
export const getMemberAddress = () =>
  http<MemberAddressItem[]>({ url: '/member/address' })

/**
* 获取收货地址详情
* @param id
* @requires
* @returns
*/
export const getMemberAddressById = (id: string) =>
  http<MemberAddressItem>({ url: `/member/address/${id}` })

/**
 * 修改收货地址
 * @param id 地址的 id
 * @param data 要修改的数据
 * @returns
 */
export const putMemberAddressById = (id: string, data: PostMemberAddressData) =>
  http({ url: `/member/address/${id}`, method: 'PUT', data })

/**
* 删除地址
* @param id
* @returns
*/
export const deleteMemberAddressById = (id: string) =>
  http({ url: `/member/address/${id}`, method: 'DELETE' })
